TdrModifyCheck
检查表结构是否发生改变
根据指定的xml文件,检查同个zone下的多张表的表结构是否发生改变
请求地址
POST
http://OmsAddress/app/newoms.php/webservice/tdr/modifycheck?cmd=10003&ip-type=webservicerest&access-token=AccessTokenVal
POST请求参数说明
参数名称 | 数据类型 | 说明 | 是否必填字段 | 备注 |
---|---|---|---|---|
app_id | 整型 | 需要检查的表所在的app的app_id | 是 | |
zone_id | 整型 | 需要检查的表所在的zone的zone_id | 是 | |
table_list | 数组 | 需要检查的表的table_name列表,如["tbl_1","tbl_2","tbl_3"],table_list为空表示检查当前区的所有表(OMS控制台版本要求3.70.1及以上支持) | 否 | |
attachment_id | 字符串 | 定义表结构的xml文件,用上传定义表结构的xml/tdr/proto文件操作接口成功上传后,返回数据的id,多个xml用逗号","相连,如"23,24" | 是 | 对于tdr为后缀的文件,只能用一个文件检查,对于xml为后缀的文件,最多64个 |
Data参数
使用json格式表示记录相关信息,示例如下:
{
"app_id": 2,
"zone_id": 3,
"attachment_id": "8",
"table_list": [
"table_generic",
"add_table1",
"add_table2",
"add_table3",
"add_table4",
"add_table5"
]
}
返回语法
返回参数说明
返回状态码不为200时,表示检查失败,返回的数据为检查失败的信息
返回状态码为200,表示检查成功,检查成功时,返回的数据为json:
字段名称 | 数据类型 | 说明 | 备注 |
---|---|---|---|
invaild_modify_table | 数组 | 利用指定的文件,不满足表变更约束的表信息 | |
same_field_table | 数组 | 利用指定的文件,表结构未发生变化的表信息 | |
diff_field_table | 数组 | 利用指定的文件,表结构发生变化、并满足表变更约束的表的信息 | |
invaild_table_in_file | 数组 | 文件中所有不符合加表规则的表 | 35.1新加 |
only_file_table | 数组 | 在xml文件中定义了此表,但是却不存在于数据库中的表 | 35.1新加 |
only_db_table | 数组 | 只存在数据库中但是在xml中找不到表定义 | 35.1新加 |
only_params_table | 数组 | 在数据库和上传的表定义文件中都不存在的表,即接口参数中table_list里没有的表名 | 35.1新加 |
请求示例
通过 curl 方法发起请求
命令中的参数请参考本页中的“POST请求参数说明”,access-token的获取方法详见:获取access-token
curl -H "Content-type: application/json" -X "POST" -d '{
"app_id": 2,
"zone_id": 3,
"attachment_id": "8",
"table_list": [
"table_generic",
"add_table1",
"add_table2",
"add_table3",
"add_table4",
"add_table5"
]
}' http://omsaddress/app/newoms.php/webservice/tdr/modifycheck?cmd=10003&ip-type=webservicerest&access-token=<access-token>
返回示例
成功返回示例
http请求的Status=200
{
"invaild_modify_table": [
{
"table_name": "table_generic",
"check_count_with_refer": true,
"value_field_num": false, #在id为5的xml文件中没有定义table_generic,不允许
"table_status": 1,
"table_type_info": {
"TableType": "1",
"ListNum": "100",
"DataProtocolType": "TBD",
"old_table_define": false
},
"data_protocol_type": "",
"error_msg": { #注:pb表文件校验这里的error_msg返回形式是数组 "error_msg":["Cannot modify feld, attempt to modify feld name, feld name: growth info.condList, table RoleData"]
"check_modify_error": "ERROR:Can't reduce list_num from 200 to 100"
}
},
{
"table_name": "add_table4",
"check_count_with_refer": true,
"value_field_num": 114,#在id为5的xml文件中,将表名为add_table4的type_int8_89字段删除了,不允许
"table_status": 1,
"table_type_info": {
"TableType": "1",
"ListNum": "100",
"DataProtocolType": "TBD",
"old_table_define": false
},
"data_protocol_type": "",
"error_msg": {
"check_modify_error": "ERROR:The entry can't be found! entry_name:'type_int8_89' metaname:'add_table4'"
}
},
{
"table_name": "add_table3",
"check_count_with_refer": true,
"value_field_num": 116,#在id为5的xml文件中,将表名为add_table4的type_int8_90字段由int8类型更改为int64,不允许
"table_status": 1,
"table_type_info": {
"TableType": "1",
"ListNum": "100",
"DataProtocolType": "TBD",
"old_table_define": false
},
"data_protocol_type": "",
"error_msg": {
"check_modify_error": "ERROR:The type of entry can't be modified! entry:'type_int8_90' metaname:'add_table3''"
}
}
],
"same_field_table": [
{
"table_name": "add_table2",
"check_count_with_refer": true,
"value_field_num": 116
},
{
"table_name": "add_table1",
"check_count_with_refer": true,
"value_field_num": 116
}
],
"diff_field_table": [
{
"table_name": "add_table5",
"check_count_with_refer": true,
"value_field_num": 117
}
],
"invaild_table_in_file": [
{
"table_name": "table_list_2",
"generic_err": "Primaykey must include splittablekey! Splittablekey:'items',table:'table_list_2' ",
"list_err": "Primaykey must include splittablekey! Splittablekey:'items',table:'table_list_2' "
}
],
"only_file_table": [
{
"table_name": "table_list_1"
}
],
"only_db_table": [
{
"table_name": "clubTable"
},
{
"table_name": "trela_core"
}
]
}
错误返回
http请求的Status!=200
{
"name": "Unauthorized",
"message": "You are requesting with an invalid credential.",
"code": 0,
"status": 401,
"type": "yii\\web UnauthorizedHttpException"
}
[
"can't get the tdr content"
]